﻿using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;

namespace Altairis.FluffyCloud.Storage {

    internal static class BlobHelper {
        public static CloudBlobContainer GalleryContainer;
        public static CloudBlobContainer UserIconContainer;
        private static CloudStorageAccount account;
        private static CloudBlobClient client;

        static BlobHelper() {
            // Create blob connection
            var connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["FluffyStorage"].ConnectionString;
            account = CloudStorageAccount.Parse(connectionString);
            client = account.CreateCloudBlobClient();

            // Ensure all containers are created
            UserIconContainer = client.GetContainerReference("usericon");
            UserIconContainer.CreateIfNotExists();
            GalleryContainer = client.GetContainerReference("gallery");
            GalleryContainer.CreateIfNotExists();
        }
    }
}